<?php namespace Home\Controller;

use Framework\Kernel\Controller;
// require 'framework/Kernel/Controller.php';

//数据库
use Framework\Model\Db;

//数据库的指定表
// use Home\Model\Stu;

//水印类
// use Framework\Tool\Water;

//缓存类
// use Framework\Tool\Cache;

//验证码类
use Framework\Tool\Code;

class IndexController extends Controller{

	protected $db;

	public function index()
	{

		$myuser = isset($_SESSION['username'])?$_SESSION['username']:'';
		$this->assign('myuser',$myuser);

		$this->db = new Db('question');

		$field = $this->db->query("select * from question order by id desc limit 10");
		// p($field);exit;
		$this->assign('field',$field);	
		//smarty模板文件调用
		$this->display('index.html');

		//单纯测试缓存类
		// $d= new Cache();
		// $d->set('a',[1,3,3]);
		// p((new Cache)->get('a'));

		// p(api('User/getUsername',[1]));
		// p(api('user/get',[2]));
		// p(S('b'));
	}

	//验证码类
	public function code()
	{
		(new Code)->show();
	}


}